import scipy.signal
def plotspec(x, Ts):
fig = figure()
ax1 = fig.add_subplot(211)
ax1.plot(x)
q = fft.fft(x)
ax2 = fig.add_subplot(212)
ax2.plot(fft.fftfreq(len(x), Ts), abs(q))
f = 20
Ts = 1/100.0
time=20
t = linspace(Ts, time, time/Ts)
w=sin(2*pi*f*t)
over=100.0
intfac=1.0
tnow = linspace(10.0/Ts, 10.5/Ts, 0.5/(Ts/intfac)).astype(int)
wsmooth = zeros(len(tnow))
for j in range(len(tnow)):
i = tnow[j]
wsmooth[j] = interpsinc(w,tnow[i], over)
k
step(tnow, w[tnow])
plot(tnow, wsmooth, "r")
def SRRC(syms, beta, P, t_off):
# syms is 1/2 the length of SRRC pulse in symbol durations
# beta is the rolloff factor (beta=0 gives sinc)
# 'P' is the oversampling factor
# t_off is the phase (or timing) offsets
pass
def SRRC2(t, T, beta):
# Taken from (11.8) on p225
if t == 0:
return 1/sqrt(T)*(1-beta+4*beta/pi)
T4b = T/(4.0*beta)
if t == T4b or t == -T4b:
return (beta/sqrt(2.0*T))*( (1+2/pi)*sin(pi/(4*beta)) + (1-2/pi)* cos(pi/(4*beta)))
ptT = pi*t/T
t4bT = 4.0*beta*t/T
return 1/sqrt(T) * sin((1-beta)*ptT) + t4bT*cos((1+beta)*ptT)/( (ptT*(1-t4bT*t4bT)))
def interpsinc(x,t,l,beta=0):
tnow = round(t)
tau = t-round(t)
s_tau = SRRC(l,beta,1,tau)
x_tau = conv(x[tnow-1:tnow+1], s_tau)
y = x_tau[2*l+1]
return y